﻿Public Class frmConsultaCursoEspecializacao
    Private curso As New _cursoEspecializacao

    Private DTVCursoEspecializacao As DataView

    Private _pmodo As String
    Private _idCursoEspecializacao As Integer
    Private _dsCursoEspecializacao As String

    Public Property idCursoEspecializacao() As Integer
        Get
            Return _idCursoEspecializacao
        End Get
        Set(ByVal value As Integer)
            _idCursoEspecializacao = value
        End Set
    End Property


    Public Property dsCursoEspecializacao() As String
        Get
            Return _dsCursoEspecializacao
        End Get
        Set(ByVal value As String)
            _dsCursoEspecializacao = value
        End Set
    End Property

    Private Sub frmCursoEspecializacao_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dgvCursosEspecializacao.AutoGenerateColumns = False
        Me.atualizaCursos()


    End Sub
    Private Sub atualizaCursos()
        DTVCursoEspecializacao = curso.consultaCursoEspecializacao.Tables("dataSet").DefaultView
        dgvCursosEspecializacao.DataSource = DTVCursoEspecializacao
    End Sub
    Private Sub btnInserir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInserir.Click
        Dim j As New frmCadastroCursoEspecializacao
        j.ShowDialog()
        Me.atualizaCursos()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Me.atualizaCursos()
    End Sub

    Public Sub New(ByVal pmodo As String)
        _pmodo = pmodo
        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

  
    Private Sub dgvCursosEspecializacao_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgvCursosEspecializacao.MouseDoubleClick

        If _pmodo = "CONSULTA" Then
            idCursoEspecializacao = dgvCursosEspecializacao.CurrentRow.Cells("O_ID_CURSOESPECIALIZACAO").Value
            dsCursoEspecializacao = dgvCursosEspecializacao.CurrentRow.Cells("O_DS_DSCURSOESPECIALIZACAO").Value

            Me.DialogResult = Windows.Forms.DialogResult.OK
            Me.Close()

        End If
    End Sub

    Private Sub txtPesquisar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPesquisar.TextChanged


        DTVCursoEspecializacao.RowFilter = "O_DS_CURSOESPECIALIZACAO LIKE '%" & txtPesquisar.Text & "%'"
        dgvCursosEspecializacao.DataSource = DTVCursoEspecializacao

    End Sub

End Class